﻿#define _CRT_SECURE_NO_WARNINGS 1

//方法一

#include<stdio.h>
int main()
{
	int count = 0;
	int n = 0;
	scanf("%d", &n);
	while (n)
	{
		n = n & (n - 1); // n & (n−1)，会将n的二进制中最低位由1变成0
		count++;
	}
	printf("%d\n", count);
	return 0;
}

//方法二

#include<stdio.h>
int main()
{
	int count = 0;
	int n = 0;
	int i = 0;
	scanf("%d", &n);
	for (i = 0; i < 32; i++)
	{
		if (n & 1 == 1)
			count++;
		n = n >> 1;
	}
	printf("%d\n", count);
	return 0;
}

//方法三

#include<stdio.h>
int main()
{
	int count = 0;
	int n = 0;
	int i = 0;
	scanf("%d", &n);
	for (i = 0; i < 32; i++)
	{
		if ((n & (1 << i)) != 0)
			count++;
	}
	printf("%d\n", count);
	return 0;
}
